package com.patMall.service.impl;

import com.patMall.entity.User;
import com.patMall.mapper.UserMapper;
import com.patMall.service.UserService;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.List;

/**
 * @Author 75099637@qq.com
 * @PackageName patMall
 * @Package com.patMall.service.impl
 * @Date 2023/12/19 10:15
 * @Version 1.0
 */
@Service
public class UserServiceImpl implements UserService {
    @Resource
    private UserMapper userMapper;

    @Override
    public List<User> getUser(String username) {
        return userMapper.selectUser(username);
    }

    @Override
    public List<User> selectByUserNameUser(String role,String userName,int count) {
        return userMapper.selectAllByUsername(role,userName,count);
    }

    @Override
    public int addUser(User user) {
        return userMapper.insert(user);
    }

    @Override
    public User getUserId(Integer userId) {
        return userMapper.selectByPrimaryKey(userId);
    }

    @Override
    public int updateUser(User user) {
        return userMapper.updateByPrimaryKey(user);
    }

    @Override
    public User selectUsername(String username) {
        return userMapper.selectUsername(username);
    }

    @Override
    public List<User> getAllByIdCard(String idCard) {
        return userMapper.selectAllByIdCard(idCard);
    }

    @Override
    public List<User> getAllByPhone(String phone) {
        return userMapper.selectAllByPhone(phone);
    }

    @Override
    public List<User> findAllUserRole(String role,int count) {
        return userMapper.selectAllUserRole(role,count);
    }
}
